package hanelsoft.vn.dictionaylearn.control.custom;

import hanelsoft.vn.dictionaylearn.R;
import hanelsoft.vn.dictionaylearn.model.entity.InfoVocabularyContent;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CustomVocabularyContent extends ArrayAdapter<InfoVocabularyContent>{
	Activity context;
	ArrayList<InfoVocabularyContent> list;
	InfoVocabularyContent info;
	public CustomVocabularyContent(Activity context,ArrayList<InfoVocabularyContent> objects) {
		super(context, R.layout.custom_vocabulary_row, objects);
		this.context = context;
		this.list = objects;
	}
	class ViewHolder
	{
		TextView rowItem;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView;
		if(convertView == null)
		{
			LayoutInflater mLayoutInflater = context.getLayoutInflater();
			rowView = mLayoutInflater.inflate(R.layout.custom_vocabulary_row, null);
			ViewHolder mViewHolder = new ViewHolder();
			mViewHolder.rowItem = (TextView)rowView.findViewById(R.id.custom_vocabulary_row_item);
			rowView.setTag(mViewHolder);
		}
		else
		{
			rowView = convertView;
		}
		ViewHolder holder = (ViewHolder)rowView.getTag();
		info = list.get(position);
		holder.rowItem.setText(info.getWord());
		return rowView;
	}
	
}
